#ifndef _MAP_UTILITY_H_
#define _MAP_UTILITY_H_

#include "array.h"
#include <functional>

#define HASHTREE_SIZE 0x1000000 // 0~ffffff, 3 * char
#define OUTER_KEY_LENGTH 3 // 3 bytes
#define INNER_KEY_LENGTH QUARTER_MAX_KMER_LEN - OUTER_KEY_LENGTH

// V: value type, possibly a pair
// K: key type, possibly pair.first
// returns input as output
template <class V, class K>
struct DummyKeyExtractor: public unary_function<V, K> {
	const K& operator()(const V& val) const {
		return val;
	}
};

// V: a pair
// K: pair.first
// returns input.first as output
template<class V, class K>
struct PairKeyExtrctor: public unary_function<pair<K, V>, K> {
	const K& operator()(const pair<const K, V>& val) const {
		return val.first;
	}
};

struct PartialKmerLess {
	bool operator()(const array<char, INNER_KEY_LENGTH>& lhs,
		const array<char, INNER_KEY_LENGTH>& rhs) const {
			return memcmp(lhs.memblock, rhs.memblock, INNER_KEY_LENGTH) < 0;
	}
};

#endif